package com.example;

import com.example.tt.Boo;
import com.example.tt.MySupplier;
import com.example.tt.ObServer;

import java.util.concurrent.*;

import static java.lang.Thread.sleep;

/**
 * @Author: wws
 * describe:
 */
public class User   {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ExecutorService service = Executors.newFixedThreadPool(10);

        LinkedBlockingQueue<String> queue = new LinkedBlockingQueue<>();

        Boo boo = new Boo(queue);
        MySupplier mySupplier = new MySupplier();
        new Thread(boo).start();
        boo.addObserver(mySupplier);

        CompletableFuture<String> integerCompletableFuture = CompletableFuture.supplyAsync(mySupplier,service);
        String a = "1";
        for (int i = 0; i < 5; i++) {
            queue.put(a);
            a += 1;
            sleep(1000);
        }

        System.out.println(integerCompletableFuture.get());
    }

}
